import type { RouteRecordRaw } from 'vue-router'
// 新增：静态导入所有页面和布局，避免动态导入导致的加载延迟
import DefaultLayout from '@/layouts/default.vue'
import HomePage from '@/pages/index.vue'
import SettingsIndex from '@/pages/settings/index.vue'
import UserInfo from '@/pages/settings/userInfo.vue'
import Account from '@/pages/settings/account.vue'
import Background from '@/pages/settings/background.vue'
import Editor from '@/pages/editor/index.vue'
import Tags from '@/pages/tags/index.vue'
import ArticlesIndex from '@/pages/articles/index.vue'
import ArticlesList from '@/pages/articles/list.vue'
import ArticlesUpload from '@/pages/articles/upload.vue'
import Shows from '@/pages/shows/index.vue'
import WebNav from '@/pages/webNav/index.vue'

export const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: DefaultLayout,
    children: [
      {
        name: 'home',
        path: '/',
        component: HomePage,
        meta: { title: '首页', icon: 'mdi-home-account' },
      },
      {
        name: 'settings',
        path: '/settings',
        component: SettingsIndex,
        children: [
          {
            name: 'userInfo',
            path: '/settings',
            component: UserInfo,
            meta: { title: '个人信息', icon: 'mdi-account-box' },
          },
          {
            name: 'account',
            path: '/settings/account',
            component: Account,
            meta: { title: '账号设置', icon: 'mdi-account-box-edit-outline' },
          },
          {
            name: 'background',
            path: '/settings/background',
            component: Background,
            meta: { title: '背景设置', icon: 'mdi-image' },
          },
        ],
        meta: { title: '设置', icon: 'mdi-cog' },
      },
      {
        name: 'editor',
        path: '/editor',
        component: Editor,
        meta: { title: '编辑器', icon: 'mdi-pencil-circle' },
      },
      {
        name: 'tags',
        path: '/tags',
        component: Tags,
        meta: { title: '文章分类', icon: 'mdi-tag-multiple' },
      },
      {
        name: 'articles',
        path: '/articles',
        component: ArticlesIndex,
        meta: { title: '文章列表', icon: 'mdi-file-multiple', noGroup: true },
        children: [
          {
            name: 'detail',
            path: '/articles',
            components: {
              default: ArticlesList,
              upload: ArticlesUpload,
            },
            meta: { title: '文章详情', icon: 'mdi-file-document-outline' },
          },
        ],
      },
      {
        name: 'shows',
        path: '/shows',
        component: Shows,
        meta: { title: '项目管理', icon: 'mdi-xml' },
      },
      {
        name: 'webNav',
        path: '/webNav',
        component: WebNav,
        meta: { title: '网站导航管理', icon: 'mdi-web' },
      },
    ],
  },
]
